package com.mz.mattress.client.api.biz;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.Card;
import com.mz.mattress.api.entity.MemberCard;
import com.mz.mattress.api.jwt.ClientJwt;
import com.mz.mattress.client.api.req.MemberCardReq;
import com.mz.mattress.client.common.Holder;
import com.mz.mattress.client.service.CardService;
import com.mz.mattress.client.service.MemberCardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@RequestMapping("card")
public class CardController {

    @Autowired
    private MemberCardService memberCardService;

    @Autowired
    private CardService cardService;

//    @GetMapping("/list")
//    public Result<List<Card>> list() {
//        ClientJwt clientJwt = Holder.CLIENT_JWT_THREAD_LOCAL.get();
//        return cardService.list(clientJwt.getMemberId());
//    }

//    @GetMapping("/listPage")
//    public Result<IPage<MemberCard>> listPage(MemberCardReq req) {
//        ClientJwt clientJwt = Holder.CLIENT_JWT_THREAD_LOCAL.get();
//        req.setMemberId(clientJwt.getMemberId());
//        return memberCardService.listPage(req);
//    }

    @GetMapping("/{id}")
    public Result<Card> detail(@PathVariable Integer id) {
        return cardService.getById(id);
    }

//    @GetMapping("/send/{id}")
//    public Result send(@PathVariable Integer id) {
//
//        ClientJwt clientJwt = Holder.CLIENT_JWT_THREAD_LOCAL.get();
//        Long memberId = clientJwt.getMemberId();
//        return memberCardService.sendCard(id, memberId);
//    }
//
//    @GetMapping("/check/{id}")
//    public Result check(@PathVariable Integer id) {
//
//        ClientJwt clientJwt = Holder.CLIENT_JWT_THREAD_LOCAL.get();
//        Long memberId = clientJwt.getMemberId();
//        return memberCardService.check(id, memberId);
//    }

}
